package com.xbongbong.workflow.service.strategy.node;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.formdata.pojo.SaasNeedRedundantAttrPojo;
import com.xbongbong.workflow.domain.entity.WorkflowNodeEntity;
import com.xbongbong.paas.config.enums.WorkflowTaskLogStatusEnum;
import com.xbongbong.paas.exception.WorkflowException;
import com.xbongbong.workflow.pojo.WorkflowProcessResultPojo;
import com.xbongbong.workflow.pojo.WorkflowTransferPOJO;

/**
 * 工作流节点策略
 * @author 魏荣杰
 * @date 2021/5/6 16:45
 * @since
 * @version
 */
public interface WorkflowNodeStrategy {

    /**
     * Description:节点类型
     * @param
     * @return com.xbongbong.workflow.enums.WorkflowNodeTypeEnum
     * @throws
     * @author 魏荣杰
     * @date 2021/5/10 16:48
     * @since
     */
    String type();

    /**
     * Description:节点前置校验等处理
     * @param
     * @param workflowTransferPOJO
     * @return void
     * @author 魏荣杰
     * @date 2021/5/10 09:51
     * @since
     */
    void before(WorkflowTransferPOJO workflowTransferPOJO);

    /**
     * Description: 节点执行
     * @param
     * @param workflowTransferPOJO 流转的数据实体
     * @param workflowNodeEntity 当前节点
     * @param lastNodeId 前一个节点的id
     * @param saasNeedRedundantAttrPojo
     * @return boolean 审批节点true：需要人审批，false不需要人审批, 其他节点true表示执行成功
     * @throws
     * @author 魏荣杰
     * @date 2021/5/6 16:46
     * @since
     */
    WorkflowProcessResultPojo process(WorkflowTransferPOJO workflowTransferPOJO, WorkflowNodeEntity workflowNodeEntity, Long lastNodeId, SaasNeedRedundantAttrPojo saasNeedRedundantAttrPojo) throws XbbException;

    /**
     * Description: 节点执行结束后封装和流转
     * @param
     * @param workflowTransferPOJO
     * @param workflowNodeEntity
     * @return void
     * @throws
     * @author 魏荣杰
     * @date 2021/5/10 09:52
     * @since
     */
    void after(WorkflowTransferPOJO workflowTransferPOJO, WorkflowNodeEntity workflowNodeEntity);

    /**
     * Description: 节点数据结构校验
     * @param
     * @return void
     * @throws
     * @author 魏荣杰
     * @date 2021/5/10 10:16
     * @since
     */
    void check();

    /**
     * Description: 创建流转日志
     * @param workflowTransferPOJO 工作流流转pojo
     * @param nodeEntity 流转到的模板节点
     * @param workflowTaskLogStatusEnum 流转节点状态
     * @param workflowException 报错
     * @see WorkflowTaskLogStatusEnum
     * @return void
     * @throws
     * @author 魏荣杰
     * @date 2021/5/13 10:46
     * @since
     */
    void logger(WorkflowTransferPOJO workflowTransferPOJO, WorkflowNodeEntity nodeEntity, WorkflowTaskLogStatusEnum workflowTaskLogStatusEnum, WorkflowException workflowException);
}
